Merge pull request #1595 from dsander/move-smtp-config

Move ActionMailer configuration to initializer

Dominik Sander 8 ans auparavant
Parent
Commettre
c1f2165383
2 fichiers modifiés avec 12 ajouts et 41 suppressions
  1. 12 6
      config/initializers/action_mailer.rb
  2. 0 35
      config/smtp.yml

+ 12 - 6
config/initializers/action_mailer.rb

@@ -1,6 +1,12 @@
1
-# Read smtp config out of a config/smtp.yml file
2
-
3
-smtp_config = YAML::load(ERB.new(File.read(Rails.root.join('config', 'smtp.yml'))).result)
4
-if smtp_config.keys.include? Rails.env
5
-  ActionMailer::Base.smtp_settings = smtp_config[Rails.env].symbolize_keys
6
-end
1
+ActionMailer::Base.smtp_settings = {
2
+  address: ENV['SMTP_SERVER'] || "smtp.gmail.com",
3
+  port: ENV['SMTP_PORT'] || 587,
4
+  domain: ENV['SMTP_DOMAIN'],
5
+  authentication: ENV['SMTP_AUTHENTICATION'] || "plain",
6
+  enable_starttls_auto: ENV['SMTP_ENABLE_STARTTLS_AUTO'] == 'true',
7
+  user_name: ENV['SMTP_USER_NAME'] || "",
8
+  password: ENV['SMTP_PASSWORD'] || "",
9
+  openssl_verify_mode: ENV['SMTP_OPENSSL_VERIFY_MODE'].presence,
10
+  ca_path: ENV['SMTP_OPENSSL_CA_PATH'].presence,
11
+  ca_file: ENV['SMTP_OPENSSL_CA_FILE'].presence
12
+}

+ 0 - 35
config/smtp.yml

@@ -1,35 +0,0 @@
1
-development:
2
-  address: <%= ENV['SMTP_SERVER'] || "smtp.gmail.com" %>
3
-  port: <%= ENV['SMTP_PORT'] || 587 %>
4
-  domain: <%= ENV['SMTP_DOMAIN'] %>
5
-  authentication: <%= ENV['SMTP_AUTHENTICATION'] || "plain" %>
6
-  enable_starttls_auto: <%= ENV['SMTP_ENABLE_STARTTLS_AUTO'] == 'true' ? true : false %>
7
-  user_name: <%= ENV['SMTP_USER_NAME'] || "" %>
8
-  password: <%= ENV['SMTP_PASSWORD'] || "" %>
9
-  openssl_verify_mode: <%= ENV['SMTP_OPENSSL_VERIFY_MODE'].presence || 'null' %>
10
-  ca_path: <%= ENV['SMTP_OPENSSL_CA_PATH'].presence || 'null' %>
11
-  ca_file: <%= ENV['SMTP_OPENSSL_CA_FILE'].presence || 'null' %>
12
-
13
-staging:
14
-  address: <%= ENV['SMTP_SERVER'] || "smtp.gmail.com" %>
15
-  port: <%= ENV['SMTP_PORT'] || 587 %>
16
-  domain: <%= ENV['SMTP_DOMAIN'] %>
17
-  authentication: <%= ENV['SMTP_AUTHENTICATION'] || "plain" %>
18
-  enable_starttls_auto: <%= ENV['SMTP_ENABLE_STARTTLS_AUTO'] == 'true' ? true : false %>
19
-  user_name: <%= ENV['SMTP_USER_NAME'] || "" %>
20
-  password: <%= ENV['SMTP_PASSWORD'] || "" %>
21
-  openssl_verify_mode: <%= ENV['SMTP_OPENSSL_VERIFY_MODE'].presence || 'null' %>
22
-  ca_path: <%= ENV['SMTP_OPENSSL_CA_PATH'].presence || 'null' %>
23
-  ca_file: <%= ENV['SMTP_OPENSSL_CA_FILE'].presence || 'null' %>
24
-
25
-production:
26
-  address: <%= ENV['SMTP_SERVER'] || "smtp.gmail.com" %>
27
-  port: <%= ENV['SMTP_PORT'] || 587 %>
28
-  domain: <%= ENV['SMTP_DOMAIN'] %>
29
-  authentication: <%= ENV['SMTP_AUTHENTICATION'] || "plain" %>
30
-  enable_starttls_auto: <%= ENV['SMTP_ENABLE_STARTTLS_AUTO'] == 'true' ? true : false %>
31
-  user_name: <%= ENV['SMTP_USER_NAME'] || "" %>
32
-  password: <%= ENV['SMTP_PASSWORD'] || "" %>
33
-  openssl_verify_mode: <%= ENV['SMTP_OPENSSL_VERIFY_MODE'].presence || 'null' %>
34
-  ca_path: <%= ENV['SMTP_OPENSSL_CA_PATH'].presence || 'null' %>
35
-  ca_file: <%= ENV['SMTP_OPENSSL_CA_FILE'].presence || 'null' %>